import $toast from '/toast'
import $http from '../http'
import $config from '../../../config'
module.exports = option => {
    const opt = { 
        url: $config.chat.url,
        corpId: $config.chat.id,
        ...option
    }
    const { url, corpId, card_open, card_img, card_title, card_path } = opt
    wx.openCustomerServiceChat({
        // 客服信息
        extInfo: {
            url                                 // 客服链接
        },
        corpId,                                 // 企业 id
        showMessageCard: Boolean(card_open),    // 是否发送小程序气泡消息
        sendMessageTitle: card_title,            // 气泡消息标题
        sendMessagePath: card_path,              // 气泡消息小程序路径
        sendMessageImg: card_img,                // 气泡消息图片
        success: res => ok?.(res),
        fail: res => $toast.msg.info('客服未启用'),
        complete(){}        
    })
}